pub mod lib {
    use std::{error::Error, fs};
    
    pub struct Config {
        pub query: String,
        pub filename: String,
    }
    
    impl Config {
        // &[String] 字符串切片
        pub fn new(args: &[String]) -> Result<Config, &str> {
            if args.len() < 3 {
                return Err("lack of args");
            }
    
            Ok(Config {
                query: args[1].clone(),
                filename: args[2].clone(),
            })
        }
    }
    
    pub fn run(config: Config) -> Result<(), Box<dyn Error>> {
        let contents = fs::read_to_string(config.filename)?;
        println!("{}", contents);
        Ok(())
    }
}
